<template>
  <div>
    <div class="setup">
      <div class="setup-nav">
        <i class="iconfont icon-xiangzuojiantou" @click="$router.go('-1')"></i>
        <span>设置</span>
      </div>
      <div class="setup-top"></div>
      <div class="setup-user" v-if="isLogin == true">
        <div class="user-img">
          <img
            src="http://p1.music.126.net/KuCKatwM2ApNNXHLHX2g2w==/109951166688773276.jpg"
            alt=""
          />
        </div>
        <div class="user-right">
          <div class="right-my">
            <span>孤城·影</span>
            <span>152****5073</span>
          </div>
          <i class="iconfont icon-youjiantou"></i>
        </div>
      </div>
      <div class="setup-items">
        <ul>
          <li v-if="isLogin == true">
            <div class="item-left">
              <span>消息推送</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li v-if="isLogin == true">
            <div class="item-left">
              <span>账号与安全</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>视频自动播放设置</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>联系我们</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>帮助中心</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>给我们打分</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>用户协议</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>隐私条款</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>系统权限设置</span>
            </div>
            <div class="item-right">
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>版本检测</span>
            </div>
            <div class="item-right">
              <span>当前版本v7.1.07.3</span>
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
          <li>
            <div class="item-left">
              <span>清理缓存</span>
            </div>
            <div class="item-right">
              <span>28M</span>
              <i class="iconfont icon-youjiantou"></i>
            </div>
          </li>
        </ul>
      </div>
      <div class="setup-bottom" v-if="isLogin == true">
        <span @click="logout()">退出登录</span>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      isLogin: false,
      token: "",
    };
  },
  methods: {
    //退出登录,删除本地存储中的token值
    logout() {
      window.localStorage.removeItem("token");
      Toast("已退出登录");
      this.$router.push("/info");
    },
  },
  created() {
    this.token = JSON.parse(localStorage.getItem("token") || "[]");
    // console.log(this.token);
    //判断没有值
    if (this.token != "") {
      this.isLogin = true;
    } else {
      this.isLogin = false;
    }
  },
};
</script>

<style lang="less">
.setup {
  padding-bottom: 15px;
  .setup-nav {
    width: 100%;
    height: 55px;
    line-height: 55px;
    border-bottom: 2px solid #ededed;
    background-color: #fff;
    position: fixed;
    z-index: 99;
    i {
      margin-left: 22px;
      font-size: 18px;
      font-weight: bold;
    }
    span {
      margin-left: 40px;
      font-size: 19px;
      font-weight: bold;
    }
  }
  .setup-top {
    height: 57px;
  }
  .setup-user {
    width: 100%;
    height: 85px;
    border-bottom: 1px solid #ededed;
    display: flex;
    align-items: center;
    .user-img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      margin-left: 22px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
    .user-right {
      width: 292px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-left: 22px;
      .right-my {
        display: flex;
        flex-direction: column;
        span:first-child {
          font-size: 17px;
          font-weight: bold;
        }
        span:last-child {
          font-size: 10px;
          font-weight: bold;
          color: #898989;
        }
      }
      i {
        font-size: 10px;
        color: #676767;
        margin-right: 14px;
      }
    }
  }
  .setup-items {
    ul {
      li {
        width: 100%;
        height: 50px;
        border-bottom: 2px solid #ededed;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .item-left {
          margin-left: 20px;
          span {
            font-size: 14px;
            font-weight: bold;
            color: #000;
          }
        }
        .item-right {
          span {
            font-size: 12px;
            color: #8f8f8f;
            margin-right: 5px;
          }
          i {
            font-size: 10px;
            color: #676767;
            margin-right: 14px;
          }
        }
      }
    }
  }
  .setup-bottom {
    width: 345px;
    height: 45px;
    line-height: 45px;
    text-align: center;
    border-radius: 20px;
    color: #000;
    background-color: #fec434;
    margin: 20px 15px 0px;
    span {
      font-size: 14px;
      font-weight: bold;
    }
  }
}
</style>